<?php
/**
 * model-书签管理
 * [ranknow bbs!] (C)2009-2015 ranknow.cn.
 *
 * @author liwei
 * @This is NOT a freeware, use is subject to license terms
 * @rcsfile $RCSfile: mdl_bookmark,v $
 * @revision $Revision: 0.1 $
 * @date $Date: 2010/01/05 14:45:17 $
 */
function add_bookmark( $data = '' ) {
    if ( !is_array( $data ) || count( $data ) == 0 ) {
        return false;
    } elseif(!check_bookmarked($data['uid'],$data['tid'])) {
        $sql = sqlMakeInsert( 'bbs_favorites', $data );
        return dbExecute( $sql );
    }
}

function check_bookmarked( $uid = '', $tid = '' ) {
    if ( $uid && $tid ) {
        $sql = "SELECT `tid` from bbs_favorites WHERE uid='$uid' AND tid='$tid'";
        $tid = dbGetOne( $sql, 'tid' );
        if ( $tid ) {
            return true;
        } else {
            return false;
        }
    }
    return false;
}

?>